<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
    pageEncoding="ISO-8859-1"%>
    <%@ taglib uri="http://java.sun.com/jstl/core" prefix="c" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>Customer - Start Page</title>
<link href="http://ajax.googleapis.com/ajax/libs/jqueryui/1.8/themes/base/jquery-ui.css" rel="stylesheet" type="text/css"/>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.4/jquery.min.js"></script>
<script src="http://ajax.googleapis.com/ajax/libs/jqueryui/1.8/jquery-ui.min.js"></script>
<script>
function editMyProfile(){
	 window.open("customer/getCustomer.do?id=<c:out value='${user.id}'></c:out>&from=customer", "register", 'height=600,width=900');
}

function viewCustomerResrevations(){
	window.open("customer/viewCustomerReservations.do", "register", 'height=600,width=900');
}
function callTimer(){
	

	var t=setTimeout("retrieveUpdates(<c:out value='${user.id}'></c:out>)",5000);
}

function retrieveUpdates(id){
	$.ajax({
		  type: "POST",
		  url: 'customer/retrieveUpdates.do',
		  data: "personId="+id,		  
		  success: retrieveUpdatesSuccess
		  
		});
}

function retrieveUpdatesSuccess(data){
	
	if(data){
		alert("You have a message");
		$("#divFlightUpdates").html(data);
		$("#divFlightUpdates").show();
	}
	callTimer();
	
}
</script>
</head>
<body onLoad="callTimer()">
<table>
	<tr>
	<td style="COLOR: #0000ff; FONT-SIZE: medium; FONT-FAMILY: 'Verdana'; FONT-WEIGHT: bold;"> Welcome <c:out value="${user.lastName}"></c:out>, <c:out value="${user.firstName}"></c:out> </td>
	
</tr>
</table>
<table>

	<tr>
		<td>
			<table>
				<tr> <td> &nbsp; </td></tr>
			
			
			</table>
		<table align="left" style="BACKGROUND-COLOR: #c0c0c0;COLOR: #004040; FONT-WEIGHT: bold; FONT-SIZE: x-small; FONT-FAMILY: 'Verdana'; vertical-align: top;border-bottom-style:solid; ; border-bottom-color: gray; 
							border-right-style:solid; ; border-right-color: gray; 
							border-left-style:solid; ; border-left-color: gray; border-top-style:solid; ; border-top-color: gray; width : 172px;">
			<tr>
				<td ><a href="javascript:editMyProfile()">Edit My Profile</a></td>
			</tr>
			
			
			<tr>
				<td><a href="javascript:viewCustomerResrevations()">View My Reservations</a></td>
			</tr>
			<tr>
				<td><a href=".">Search Flights</a></td>
			</tr>
			
			
		</table>		
		</td>
		<td>
			<div id="divFlightUpdates">
						
			
			</div>
		
		</td>
		
	</tr>
</table>

</body>
</html>